
package com.hm.jiaowuxitong.ui;

        import com.hm.jiaowuxitong.service.IStudentService;
        import com.hm.jiaowuxitong.service.StudentServiceImp;
        import com.hm.jiaowuxitong.util.DBUtil;
        import com.hm.jiaowuxitong.util.UIUtil;
        import org.junit.Test;

        import javax.swing.*;
        import java.awt.*;
        import java.awt.event.MouseEvent;
        import java.awt.event.MouseListener;
        import java.util.HashMap;
        import java.util.Map;

public class ShowStudentGradeButton {
    private int frame_width=770;
    private int frame_height=460;


    public ShowStudentGradeButton(){
        //创建添加学生信息的面板
        JFrame frame=new JFrame("查询学生成绩");
        //设置面板的宽高
        frame.setSize(frame_width,frame_height);
        //禁止面板放大缩小
        frame.setResizable(true);
        //创建画布
        JPanel panel=new JPanel();
        //创建方向布局
        SpringLayout layout=new SpringLayout();
        panel.setLayout(layout);
        //创建文本框控件
        JLabel label1=new JLabel("查询人学号:");
        layout.putConstraint(SpringLayout.WEST,label1,205,SpringLayout.WEST,panel);
        layout.putConstraint(SpringLayout.NORTH,label1,50,SpringLayout.NORTH,panel);
        label1.setForeground(Color.black);
        label1.setFont(new Font(" ", 3, 20));
        //创建文本编辑框控件
        JTextField jtf1=new JTextField(15);
        layout.putConstraint(SpringLayout.NORTH,jtf1,57,SpringLayout.NORTH,panel);
        layout.putConstraint(SpringLayout.WEST,jtf1,5,SpringLayout.EAST,label1);
        jtf1.setForeground(Color.black);
        jtf1.setFont(new Font(" ", 3, 15));

        //创建提交按钮
        JButton button=new JButton("提交");
        layout.putConstraint(SpringLayout.WEST,button,305,SpringLayout.WEST,panel);
        layout.putConstraint(SpringLayout.NORTH,button,300,SpringLayout.NORTH,panel);
        button.setForeground(Color.black);
        button.setFont(new Font(" ", 3, 15));
        JButton button1=new JButton("返回");
        layout.putConstraint(SpringLayout.WEST,button1,20,SpringLayout.EAST,button);
        layout.putConstraint(SpringLayout.NORTH,button1,300,SpringLayout.NORTH,panel);
        button1.setForeground(Color.black);
        button1.setFont(new Font(" ", 3, 15));

        JLabel img=new JLabel();
        ImageIcon imageIcon = new ImageIcon("Image/nh2.png");  // 将"path/to/your/image.jpg"替换为你的图片路径
        img.setIcon(imageIcon);

        //把所有控件添加至画布
        panel.add(label1);
        panel.add(jtf1);

        panel.add(button);
        panel.add(button1);
        panel.add(img);
        //把画布添加至面板
        frame.setContentPane(panel);
        //将面板中央显示
        new UIUtil().center(frame,frame_width,frame_height);
        //将面板显示
        frame.setVisible(true);
        //添加提交按钮的点击事件
        button.addMouseListener(new MouseListener() {
            @Override
            public void mouseClicked(MouseEvent e) {

            }

            @Override
            public void mousePressed(MouseEvent e) {
                //获得所有编辑框中添加的内容信息
                String personId=jtf1.getText();

                new ShowSelfGradeInfoList(personId);

            }

            @Override
            public void mouseReleased(MouseEvent e) {

            }

            @Override
            public void mouseEntered(MouseEvent e) {

            }

            @Override
            public void mouseExited(MouseEvent e) {

            }
        });
        button1.addMouseListener(new MouseListener() {
            @Override
            public void mouseClicked(MouseEvent e) {

            }

            @Override
            public void mousePressed(MouseEvent e) {

                frame.dispose();

            }

            @Override
            public void mouseReleased(MouseEvent e) {

            }

            @Override
            public void mouseEntered(MouseEvent e) {

            }

            @Override
            public void mouseExited(MouseEvent e) {

            }
        });


    }

    public void delete(String id){
        DBUtil.jt.update("delete from 学生表 where 姓名=?", new Object[]{id});


//        System.out.println(
//                (jt.update("delete from tb_student where id=?", new Object[]{21})>0
//                        ?"删除成功":"删除失败"));
    }
    public void UpdateStudentAge(String id,String age){
        DBUtil.jt.update("update 学生表 set 年龄=? where 姓名=?",
                new Object[]{age, id});

    }
    public void UpdateStudentSex(String id,String sex){
        DBUtil.jt.update("update 学生表 set 性别=? where 姓名=?",
                new Object[]{sex, id});

    }
    public void UpdateStudentClass(String id,String clas){
        DBUtil.jt.update("update 学生表 set 班级号=? where 姓名=?",
                new Object[]{clas, id});

    }

    public static void main(String[] args) {
        new ShowStudentGradeButton();
    }



}
